import { getServerSession } from 'next-auth';
import { redirect } from 'next/navigation';
import { LoginButtons } from './LoginButtons';

export default async function LoginPage({
  searchParams,
}: {
  searchParams: { registered?: string };
}) {
  const session = await getServerSession();
  if (session) {
    redirect('/');
  }

  return (
    <div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
      <div className="max-w-md w-full space-y-8">
        <div>
          <h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900">
            登录账户
          </h2>
          {searchParams.registered && (
            <div className="mt-2 text-center text-sm text-green-600">
              注册成功！请登录
            </div>
          )}
          <p className="mt-2 text-center text-sm text-gray-600">
            或者{' '}
            <a href="/register" className="font-medium text-blue-600 hover:text-blue-500">
              创建新账号
            </a>
          </p>
        </div>
        <LoginButtons />
      </div>
    </div>
  );
} 